//
//  THAttributedString.m
//  TaiHaoCloud
//
//  Created by LeeSongtao on 16/6/16.
//  Copyright © 2016年 rzm. All rights reserved.
//

#import "SampuxAttributedString.h"

@implementation SampuxAttributedString

+ (NSAttributedString *)handleUnitStringWithUnderline:(NSString *)fullStr unitFont:(CGFloat)unitFont numFont:(CGFloat)numFont unitString:(NSString *)unitStr underline:(NSUnderlineStyle)lineStyle
{
    

    NSDictionary *numDict = [NSDictionary dictionaryWithObjectsAndKeys:THFont(numFont),NSFontAttributeName,THWhiteAlplaColor(0.9),NSForegroundColorAttributeName, nil];
    NSDictionary *unitDict = [NSDictionary dictionaryWithObjectsAndKeys:THFont(unitFont),NSFontAttributeName,THWhiteAlplaColor(0.6),NSForegroundColorAttributeName,@(lineStyle),NSUnderlineStyleAttributeName, nil];
    

    NSRange range = [fullStr rangeOfString:unitStr];
    NSMutableAttributedString *mutStr = [[NSMutableAttributedString alloc]initWithString:fullStr attributes:numDict];
    
    [mutStr setAttributes:unitDict range:range];
    return mutStr;
    
}

+ (NSAttributedString *)handleUnitString:(NSString *)fullStr unitFont:(CGFloat)unitFont numFont:(CGFloat)numFont unitString:(NSString *)unitStr
{
    return [self handleUnitStringWithUnderline:fullStr unitFont:unitFont numFont:numFont unitString:unitStr underline:NSUnderlineStyleNone];
}
//+ (NSString *)getUnitStringWithTHUnitType:(THUnitType)type
//{
//    NSString *unitStr = @"";
//    switch (type) {
//        case THUnitType_ugm3:
//            unitStr = @"ug/m³";
//            
//            break;
//         case THUnitType_ppm:
//            unitStr = @"ppm";
//            break;
//        case THUnitType_C:
//            unitStr = @"℃";
//            break;
//        case THUnitType_grade:
//            unitStr = @"档";
//            break;
//        case THUnitType_RH:
//            unitStr = @"%RH";
//            break;
//            
//        case THUnitType_number:
//            unitStr = @"个";
//            break;
//        default:
//            break;
//    }
//    return unitStr;
//}


@end
